Imports DAL

Imports MyClasses
Imports System.Configuration

Public Class frmEmpMaster
    Dim _intEmpID As Integer
    Dim intAddress As Integer
    Dim address(0) As CAddress
    'Dim intpersonid As Integer
    Dim intaddrC As Integer
    Dim intaddrS As Integer
    Dim intaddrCi As Integer

    'Dim flag As Boolean
    Dim blnFlagAddType As Boolean
    Dim blnCountryFlag As Boolean
    Dim blnStateFlag As Boolean
    Dim blnCityFlag As Boolean
    'Dim strCity As String

    Dim updtAddress(0) As CAddress
    Dim flgUser As Byte

    'Rahul_ITS@2007113 : Add following line
    Private Sub cmbTitle_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbTitle.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    txtLname.Focus()
                Else
                    txtFname.Focus()
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbTitle_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Divya@13/02/2008 : Added for Tab key sequence for Name
    Private Sub cmbTitle_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTitle.Leave
        Try
            If Keys.Tab Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    txtLname.Focus()
                    txtLname.Tag = txtLname.Text
                Else
                    txtFname.Focus()
                    txtFname.Tag = txtFname.Text
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbTitle_Leave")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtFname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFname.GotFocus
        If btnSave.Text = "&Save" Then If txtFname.Text = txtFname.Tag Then txtFname.Text = ""
    End Sub

    'Rahul_ITS@20071113 : Add following line
    Private Sub txtFname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFname.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                txtMname.Focus()
            Else
                If e.Shift = True Then
                    If e.KeyCode = Keys.OemQuotes Then
                        e.SuppressKeyPress = True
                    End If
                    If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                        e.SuppressKeyPress = True
                    End If
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtFname_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtLname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.GotFocus
        If btnSave.Text = "&Save" Then If txtLname.Text = txtLname.Tag Then txtLname.Text = ""
    End Sub

    'Rahul_ITS@20071113 : Add following line
    Private Sub txtLname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtLname.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    txtFname.Focus()
                Else
                    cmbQual.Focus()
                End If
            Else
                If e.Shift = True Then
                    If e.KeyCode = Keys.OemQuotes Then
                        e.SuppressKeyPress = True
                    End If
                    If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                        e.SuppressKeyPress = True
                    End If
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtLname_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Divya@13/02/2008 : Added for Tab key sequence for Name
    Private Sub txtLname_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.Leave
        Try
            If Keys.Tab Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    txtFname.Focus()
                    'txtFname.Tag = txtFname.Text
                    'txtMname.Tag = txtMname.Text
                    'Else
                    '    cmbQual.Focus()
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtLname_Leave")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.GotFocus
        If btnSave.Text = "&Save" Then If txtMname.Text = txtMname.Tag Then txtMname.Text = ""
    End Sub

    'Rahul_ITS@20071113 : Add following line
    Private Sub txtMname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMname.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    cmbQual.Focus()
                Else
                    txtLname.Focus()
                End If
            Else
                If e.Shift = True Then
                    If e.KeyCode = Keys.OemQuotes Or e.KeyCode = Keys.OemPeriod Then
                        e.SuppressKeyPress = True
                    End If
                    If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                        e.SuppressKeyPress = True
                    End If
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMname_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Divya@13/02/2008 : Added for Tab key sequence for Name
    Private Sub txtMname_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.Leave
        Try
            If Keys.Tab Then
                If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                    cmbQual.Focus()
                    cmbQual.Tag = cmbQual.Text
                Else
                    txtLname.Focus()
                    'txtLname.Tag = txtLname.Text

                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMname_Leave")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbQual_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbQual.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then dtpJoinDate.Focus()
    End Sub

    Private Sub cmbAddrType_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbAddrType.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtAddr1.Focus()
    End Sub

    Private Sub txtaddr1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtAddr1.KeyDown
        Try
            'Rahul_ITS@20071113 : Add following line
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                cmbCountry.Focus()
            Else
                If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtaddr1_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbcity_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbCity.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtPinCode.Focus()
    End Sub

    Private Sub txtPincode_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPinCode.KeyDown
        Try
            'Rahul_ITS@20071113 : Add following line 
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                txtPhone1.Focus()
            Else
                If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtPincode_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbstate_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbState.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbCity.Focus()
    End Sub

    Private Sub cmbCountry_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.GotFocus
        If cmbCountry.SelectedValue = Nothing Then
            cmbCountry.SelectedValue = ConfigurationManager.AppSettings("Country")
        End If
    End Sub

    Private Sub cmbcountry_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbCountry.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbState.Focus()
    End Sub

    Private Sub txtphone1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone1.KeyDown
        Try
            'Rahul_ITS@20071113 : Add following line
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtPhone2.Focus()
            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtphone1_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtPhone1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone1.KeyUp
        Try
            If (BCommon.IsInteger(txtPhone1.Text) = False) Then txtPhone1.Focus() : txtPhone1.Text = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtPhone1_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtphone2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone2.KeyDown
        Try
            'Rahul_ITS@20071113 : Add following line
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtFax.Focus()
            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtphone2_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtPhone2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone2.KeyUp
        Try
            If (BCommon.IsInteger(txtPhone2.Text) = False) Then txtPhone2.Focus() : txtPhone2.Text = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtPhone2_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtfax_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFax.KeyDown
        Try
            'Rahul_ITS@20071113 : Add following line
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtEmail.Focus()
            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtfax_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtfax_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFax.KeyUp
        Try
            If (BCommon.IsInteger(txtFax.Text) = False) Then txtFax.Focus() : txtFax.Text = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtfax_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtEmpID_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtEmpID.KeyDown
        'Rahul_ITS@20071113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbTitle.Focus()
    End Sub

    Private Sub dtpJoinDate_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dtpJoinDate.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtBasicSal.Focus()
    End Sub

    Private Sub cmbCountry_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectedIndexChanged
        If blnCountryFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        Call GetCountryState()
    End Sub

    Private Sub cmbState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbState.SelectedIndexChanged
        If blnStateFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        intaddrS = cmbState.SelectedValue
        Call GetStateCity(intaddrS)
    End Sub

    Private Sub cmbCity_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCity.SelectedIndexChanged
        If blnCityFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        If cmbCity.Items.Count > 0 Then
            intaddrCi = cmbCity.SelectedValue
            Call GetCityPincode(intaddrCi)
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If btnSave.Text = "&Update" Then btnSave.Text = "&Save"
            btnDelete.Enabled = False
            btnSetUser.Enabled = False
            Call DisplayData()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnCancel_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtFname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFname.LostFocus
        Try
            txtFname.Text = IIf(Trim(txtFname.Text) = "", txtFname.Tag, Trim(txtFname.Text))
            If txtFname.Text <> "" Or txtFname.Text <> txtFname.Tag Then
                txtFname.Text = UCase(Mid(txtFname.Text, 1, 1)) & Mid(txtFname.Text, 2)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtFname_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.LostFocus
        Try
            txtMname.Text = IIf(Trim(txtMname.Text) = "", txtMname.Tag, Trim(txtMname.Text))
            If txtMname.Text <> "" Or txtMname.Text <> txtFname.Tag Then
                txtMname.Text = UCase(Mid(txtMname.Text, 1, 1)) & Mid(txtMname.Text, 2)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMname_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtLname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.LostFocus
        Try
            txtLname.Text = IIf(Trim(txtLname.Text) = "", txtLname.Tag, Trim(txtLname.Text))
            If txtLname.Text <> "" Or txtLname.Text <> txtFname.Tag Then
                txtLname.Text = UCase(Mid(txtLname.Text, 1, 1)) & Mid(txtLname.Text, 2)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtLname_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub
   
    Private Sub cmbAddrType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAddrType.SelectedIndexChanged
        If blnFlagAddType = False Then Me.Cursor = Cursors.Default : Exit Sub
        Try
            If isAddressChanged() = 1 Then Call SetAddress(intAddress)
            Call clear_addr()
            intAddress = cmbAddrType.SelectedIndex
            If intAddress >= 0 Then
                Call Getaddress(intAddress)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbAddrType_SelectedIndexChanged")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Me.Cursor = Cursors.WaitCursor
        If SaveData() Then
            Call DisplayData()
        End If
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub frmEmpMaster_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Not (ConfigurationManager.AppSettings("FormMode") = "R") Then
                If isUpdate() Then
                    Select Case BCommon.ShowMsgError(10081, "YNC")
                        Case Windows.Forms.DialogResult.Yes
                            Call SaveData()
                        Case Windows.Forms.DialogResult.Cancel
                            e.Cancel = True
                        Case Windows.Forms.DialogResult.No
                    End Select
                End If
                Me.Cursor = Cursors.Default
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "frmEmpMaster_FormClosing")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub frmEmpMaster_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        'Rauhl_ITS@20073012 : Add following code display help
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Employee")
        e.Cancel = True
    End Sub

    Private Sub frmEmpMaster_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            'Rauhl_ITS@20073012 : Add following code display help
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Employee")
        End If
    End Sub

    Private Sub frmEmpMaster_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave

    End Sub

    Private Sub frmEmpMaster_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Call BCommon.SetFormStandards(Me)
            BCommon.SetDatePickerMaxMinDate(dtpJoinDate)
            DisplayData()
            btnSetUser.Enabled = False
            'txtEmpID.Enabled = False
            dtpJoinDate.Focus()
            ReDim address(cmbAddrType.Items.Count)
            ReDim updtAddress(cmbAddrType.Items.Count)
            intAddress = 0
            'strCity = ConfigurationManager.AppSettings("City")
            blnFlagAddType = True
            blnCountryFlag = True
            blnStateFlag = True
            blnCityFlag = True
            'txtEmpID.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "frmEmpMaster_Load")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnSetUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetUser.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim form As New frmNewUser
            form.intEmpNo = _intEmpID
            form.ShowDialog()
            If form.intEmpNo = 0 Then btnSetUser.Enabled = False
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSetUser_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Validation of the controls
    Private Function ValidateData() As Boolean
        Try
            If Trim(txtFname.Text) = "<First Name>" Or Trim(txtFname.Text) = "" Then
                BCommon.ShowMsgError(10011)
                txtFname.Focus()
                Return False
            End If

            If Trim(txtLname.Text) = "<Last Name>" Or Trim(txtLname.Text) = "" Then
                BCommon.ShowMsgError(10012)
                txtLname.Focus()
                Return False
            End If
            If Trim(txtBasicSal.Text) = "" OrElse Trim(txtBasicSal.Text) = "0.00" Then
                BCommon.ShowMsgError(10121)
                txtBasicSal.Focus()
                Return False
            End If

            If Trim(txtEmail.Text) <> "" Then
                If BCommon.ValidateEmailID(txtEmail.Text) = False Then
                    txtEmail.Focus()
                    Return False
                End If
                ValidateData = True
            End If

            If Date.Today < dtpJoinDate.Value Then
                'MessageBox.Show("Joining Date can not be Future Date")
                BCommon.ShowMsgError(10395)
                dtpJoinDate.Focus()
                Return False
            End If

            If Trim(txtPhone1.Text) <> "" Or Trim(txtPhone2.Text) <> "" Then
                If Trim(txtPhone1.Text) = Trim(txtPhone2.Text) Then
                    BCommon.ShowMsgError(10002)
                    txtPhone2.Focus()
                    Return False
                End If
            End If
            Return True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ValidateData")
            Me.Cursor = Cursors.Default
            Return False
        End Try
    End Function

    'DISPLAY THE DATA WHILE THE FORM IS LOADED
    Private Sub DisplayData()
        Try
            Dim dtbCountry As New DataTable
            Call ClearData()
            txtEmpID.Text = BCommon.GetSequentialID("EMP")
            dtbCountry = DAddress.GetCountry()

            blnFlagAddType = False
            blnCountryFlag = False
            blnStateFlag = False
            blnCityFlag = False
            BCommon.SetComboValues(cmbQual, "EMPQUALIFICATION")
            BCommon.SetComboValues(cmbTitle, "TITLE")
            BCommon.SetComboValues(cmbAddrType, "ADDRESS_TYPE")
            BCommon.SetComboValues(cmbCountry, dtbCountry, "CountryCD", "Description")

            cmbTitle.SelectedValue = Replace(ConfigurationManager.AppSettings("Title"), ".", "")
            cmbTitle.Tag = cmbTitle.SelectedValue
            cmbQual.Tag = cmbQual.SelectedValue
            cmbCountry.SelectedIndex = -1
            cmbState.SelectedIndex = -1
            cmbCity.SelectedIndex = -1
            Call SetcontrolTag()
            BCommon.SetTextReadOnly(txtEmpID) 'Divya 31/01/2008 : Added for ReadOnly fields

            blnFlagAddType = True
            blnCountryFlag = True
            blnStateFlag = True
            blnCityFlag = True
            txtFname.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "DisplayData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    ' Assign values to the CEmployee Object
    Private Function SetData() As CEmployee
        Dim objEmployee As New CEmployee
        Try
            With objEmployee
                .EmpID = _intEmpID 'Trim(txtEmpID.Text)
                .qualification = cmbQual.SelectedValue
                .BasicSal = Trim(txtBasicSal.Text)
                '.DateOfJoining = dtpJoinDate.Text.Substring(6, 4) + dtpJoinDate.Text.Substring(3, 2) + dtpJoinDate.Text.Substring(0, 2)
                .DateOfJoining = dtpJoinDate.Value
            End With

            With objEmployee.person
                If btnSave.Text = "&Save" Then
                    .Title = cmbTitle.SelectedValue
                    .First_Name = IIf(Trim(txtFname.Text) <> txtFname.Tag, Trim(txtFname.Text), "")
                    .Middle_Name = IIf(Trim(txtMname.Text) <> txtMname.Tag, Trim(txtMname.Text), "")
                    .Last_Name = IIf(Trim(txtLname.Text) <> txtLname.Tag, Trim(txtLname.Text), "")
                    ' .Display_Name = (Trim(txtFname.Text)) + (Trim(txtLname.Text))
                Else
                    .Title = cmbTitle.SelectedValue
                    .First_Name = Trim(txtFname.Text)
                    .Middle_Name = Trim(txtMname.Text)
                    .Last_Name = Trim(txtLname.Text)
                    .Display_Name = (Trim(txtFname.Text)) + (Trim(txtLname.Text))
                End If
            End With
            Return objEmployee
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetData")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Private Function SaveData() As Boolean
        Dim blnResult As Boolean
        Try
            If ValidateData() = False Then Me.Cursor = Cursors.Default : Exit Function
            Dim objEmployee As CEmployee
            objEmployee = SetData()
            If btnSave.Text = "&Save" Then
                blnResult = DEmployee.SaveEmployee(objEmployee, "S", SetAddress())
                If blnResult = True Then BCommon.ShowMsgError(3) Else BCommon.ShowMsgError(4)
            Else
                blnResult = DEmployee.SaveEmployee(objEmployee, "U", SetAddress())
                If blnResult = True Then
                    BCommon.ShowMsgError(5)
                    btnSave.Text = "&Save"
                    btnDelete.Enabled = False
                Else
                    BCommon.ShowMsgError(4)
                End If
            End If
            Return blnResult
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SaveData")
            Me.Cursor = Cursors.Default
            Return False
        End Try
    End Function

    ' Set Address according to the Address Type selected
    Private Function SetAddress(ByVal IntAddress As Integer) As CAddress()
        Try
            Dim intAddressID As Integer = 0
            If Not IsNothing(address(IntAddress)) Then
                intAddressID = address(IntAddress).AddressID
            End If
            address(IntAddress) = New CAddress
            address(IntAddress).AddressID = intAddressID
            With address(IntAddress)
                .AddressType = cmbAddrType.Items(IntAddress).item(0).ToString()
                .Description1 = Trim(txtAddr1.Text)
                '.Description2 = Trim(txtAddr2.Text)
                .Country = cmbCountry.SelectedValue
                .State = cmbState.SelectedValue
                .PinCode = IIf(Trim(txtPinCode.Text) <> "", Trim(txtPinCode.Text), 0)
                If cmbCity.SelectedValue = Nothing Then
                    If cmbCity.Text <> "" Then
                        .City = DAddress.SaveCity(.State, .Country, cmbCity.Text, .PinCode)
                    End If
                Else
                    .City = cmbCity.SelectedValue
                End If
                .PhoneNo1 = Trim(txtPhone1.Text)
                .PhoneNo2 = Trim(txtPhone2.Text)
                .Fax = IIf(Trim(txtFax.Text) <> "", Trim(txtFax.Text), 0)
                .EmailID = Trim(txtEmail.Text)
                '.WebSiteAddress = Trim(txtWebSite.Text)
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetAddress")
            Me.Cursor = Cursors.Default
        End Try
        Return address
    End Function

    'Set the Address Information from controls to Address array
    Private Function SetAddress() As CAddress()
        Try
            Dim intAddressID As Integer = 0
            If Not IsNothing(address(cmbAddrType.SelectedIndex)) Then
                intAddressID = address(cmbAddrType.SelectedIndex).AddressID
            End If
            If isAddressChanged() = 1 Then
                address(cmbAddrType.SelectedIndex) = New CAddress
                address(cmbAddrType.SelectedIndex).AddressID = intAddressID
                With address(cmbAddrType.SelectedIndex)
                    .AddressType = Trim(cmbAddrType.SelectedValue)
                    .Description1 = Trim(txtAddr1.Text)
                    .Country = cmbCountry.SelectedValue
                    .State = cmbState.SelectedValue
                    .PinCode = IIf(Trim(txtPinCode.Text) <> "", Trim(txtPinCode.Text), 0)
                    If cmbCity.SelectedValue = Nothing Then
                        If cmbCity.Text <> "" Then
                            .City = DAddress.SaveCity(.State, .Country, cmbCity.Text, .PinCode)
                        End If
                    Else
                        .City = cmbCity.SelectedValue
                    End If
                    .PhoneNo1 = Trim(txtPhone1.Text)
                    .PhoneNo2 = Trim(txtPhone2.Text)
                    .Fax = IIf(Trim(txtFax.Text) <> "", Trim(txtFax.Text), 0)
                    .EmailID = Trim(txtEmail.Text)
                    '.WebSiteAddress = Trim(txtWebSite.Text)
                End With
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetAddress")
            Me.Cursor = Cursors.Default
        End Try
        Return address
    End Function

    'Retrives Address from the database
    Private Sub Getaddress(ByVal intC As Integer)
        Try
            If IsNothing(address(intC)) Then
                Me.Cursor = Cursors.Default
                Exit Sub
            End If
            With address(intC)
                txtAddr1.Text = .Description1
                txtAddr1.Tag = .Description1
                cmbCountry.SelectedValue = .Country
                cmbCountry.Tag = .Country
                cmbState.SelectedValue = .State
                cmbState.Tag = .State
                cmbCity.SelectedValue = .City
                cmbCity.Tag = .City
                txtPinCode.Text = .PinCode
                txtPinCode.Tag = .PinCode
                txtPhone1.Text = .PhoneNo1
                txtPhone1.Tag = .PhoneNo1
                txtPhone2.Text = .PhoneNo2
                txtPhone2.Tag = .PhoneNo2
                txtFax.Text = IIf(.Fax = 0, "", .Fax)
                txtFax.Tag = IIf(.Fax = 0, "", .Fax)
                txtEmail.Text = .EmailID
                txtEmail.Tag = .EmailID
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "Getaddress")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Displays the person information 
    Private Sub ViewPerson(ByVal personid As Integer)
        Dim dtsPerson As New DataSet
        Try
            dtsPerson = DEmployee.GetPerson(personid)
            With dtsPerson.Tables(0).Rows(0)
                cmbTitle.SelectedValue = .Item(0)
                cmbTitle.Tag = .Item(0)
                txtFname.Text = .Item(1)
                txtFname.Tag = .Item(1)
                txtMname.Text = .Item(2)
                txtMname.Tag = .Item(2)
                txtLname.Text = .Item(3)
                txtLname.Tag = .Item(3)
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ViewPerson")
            Me.Cursor = Cursors.Default
        End Try

    End Sub

    'Displays the Address Information of the corresponding Employee
    Private Sub ViewAddress(ByVal intPersonID As Integer)
        Dim dtbAddr As New DataTable
        Dim intc As Integer = 0
        Dim intCount, intAddrCount As Integer
        Try
            dtbAddr = DAddress.SearchAddress(intPersonID)
            For intAddrCount = 0 To dtbAddr.Rows.Count - 1
                'For Each row As DataRow In dtbAddr.Rows
                If IsNothing(dtbAddr.Rows(intc)) Then Me.Cursor = Cursors.Default : Exit Sub

                For intCount = 0 To cmbAddrType.Items.Count - 1
                    If cmbAddrType.DataSource.Rows(intCount).Item(0).ToString() = dtbAddr.Rows(intc).Item(0).ToString() Then
                        Exit For
                    End If
                Next
                With dtbAddr.Rows(intc)
                    address(intCount) = New CAddress
                    address(intCount).AddressType = .Item(0)
                    address(intCount).Description1 = .Item(1)
                    address(intCount).Description2 = .Item(2)
                    address(intCount).PinCode = .Item(3)
                    address(intCount).City = .Item(4)
                    address(intCount).State = .Item(5)
                    address(intCount).Country = .Item(6)
                    address(intCount).PhoneNo1 = .Item(7)
                    address(intCount).PhoneNo2 = .Item(8)
                    If Trim(.Item(11)) = "" Then
                        address(intCount).Fax = "0"
                    Else
                        address(intCount).Fax = .Item(11)
                    End If

                    address(intCount).EmailID = .Item(12)
                    address(intCount).WebSiteAddress = .Item(13)
                    address(intCount).AddressID = .Item(14)
                    intc = intc + 1
                End With
            Next
            If dtbAddr.Rows.Count > 0 Then
                If cmbAddrType.SelectedValue <> dtbAddr.Rows(0).Item(0) Then
                    blnFlagAddType = False
                    cmbAddrType.SelectedValue = dtbAddr.Rows(0).Item(0)
                    blnFlagAddType = True
                End If
                intAddress = cmbAddrType.SelectedIndex
                CCommon.CopyArray(address, updtAddress) 'copy address array to updatearray
                Call Getaddress(intAddress)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ViewAddress()")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    '   Clear the Address Controls
    Private Sub clear_addr()
        Try
            txtAddr1.Text = ""
            txtAddr1.Tag = ""
            cmbCountry.SelectedIndex = -1
            cmbCountry.Tag = Nothing
            cmbState.SelectedIndex = -1
            cmbState.Tag = Nothing
            cmbCity.SelectedIndex = -1
            cmbCity.Tag = Nothing
            txtPinCode.Text = ""
            txtPinCode.Tag = ""
            txtPhone1.Text = ""
            txtPhone1.Tag = ""
            txtPhone2.Text = ""
            txtPhone2.Tag = ""
            txtFax.Text = ""
            txtFax.Tag = ""
            txtEmail.Text = ""
            txtEmail.Tag = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "clear_addr")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Clear the Address Array
    Private Sub ClearAddress()
        Try
            Dim intCount As Integer
            intAddress = 0
            For intCount = 0 To address.Length - 1
                address(intCount) = Nothing
                updtAddress(intCount) = Nothing
            Next
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ClearAddress")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Displays the State name according to the Country Name Selected
    Private Sub GetCountryState()
        Dim dtcountry As New DataTable
        Try
            intaddrC = cmbCountry.SelectedValue
            dtcountry = DAddress.GetCountryStates(intaddrC)
            blnStateFlag = False
            BCommon.SetComboValues(cmbState, dtcountry, "StateCD", "Description")
            blnStateFlag = True
            If ConfigurationManager.AppSettings("Country") = cmbCountry.SelectedValue Then
                cmbState.SelectedValue = ConfigurationManager.AppSettings("State")
                cmbState.Refresh()
            Else
                cmbCity.Text = ""
                txtPinCode.Text = ""
                cmbState.Text = ""
            End If
            GetStateCity(cmbState.SelectedValue)

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetCountryState")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Displays the city name according to the state selected
    Private Sub GetStateCity(ByVal intaddrS As Integer)
        Dim dtstate As New DataTable
        Try
            intaddrC = cmbCountry.SelectedValue
            dtstate = DAddress.GetStateCity(intaddrS, intaddrC)
            blnCityFlag = False
            BCommon.SetComboValues(cmbCity, dtstate, "CityCD", "Description")
            blnCityFlag = True
            If cmbCity.Items.Count > 0 Then
                If ConfigurationManager.AppSettings("Country") = cmbCountry.SelectedValue And ConfigurationManager.AppSettings("State") = cmbState.SelectedValue Then cmbCity.SelectedValue = ConfigurationManager.AppSettings("City")
            Else
                cmbCity.Text = ""
                txtPinCode.Text = ""
            End If
            cmbCity.Refresh()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetStateCity")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    '   Displays the pincode of the corresponding city
    Private Sub GetCityPincode(ByVal intaddrci As Integer)
        Dim intpincode As Integer
        Try
            intpincode = DAddress.GetCityPinCode(intaddrci)
            txtPinCode.Text = intpincode
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetCityPincode")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Dispalys the Empoyee Information
    Private Sub ViewEmpoyee()
        Dim dtsEmpoyee As New DataSet
        Try
            dtsEmpoyee = DEmployee.GetEmployee(_intEmpID)

            If dtsEmpoyee.Tables(0).Rows.Count > 0 Then
                With dtsEmpoyee.Tables(0).Rows(0)
                    flgUser = DEmployee.IsUser(.Item(3))
                    txtEmpID.Text = .Item(1)
                    txtEmpID.Tag = .Item(1)
                    cmbQual.SelectedValue = .Item(2)
                    cmbQual.Tag = .Item(2)
                    txtBasicSal.Text = .Item(4)
                    txtBasicSal.Tag = .Item(4)
                    dtpJoinDate.Value = .Item(5)
                    dtpJoinDate.Tag = .Item(5)
                    Call ViewPerson(.Item(3))
                    Call ViewAddress(.Item(3))
                End With
            Else
                'need 2 b changed
                BCommon.ShowMsgError(10082)
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ViewEmpoyee")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'To clear all the Text or Combo Control
    Private Sub ClearData()
        Try
            Dim dtFinYr As New DataTable
            Dim strMsg As String = String.Empty
            dtFinYr = DFinancialYear.GetActiveFinyear(ConfigurationManager.AppSettings("FirmID"))
            If dtFinYr.Rows.Count > 0 Then
                If Now.Date < dtFinYr.Rows(0).Item("Fin_start_dt").date OrElse Now.Date > dtFinYr.Rows(0).Item("fin_end_dt") Then
                    BCommon.ShowMsgError(10437)
                End If
            End If
            dtpJoinDate.Value = Now.Date
            If cmbQual.Items.Count > 0 Then cmbQual.SelectedIndex = 0 : cmbQual.Tag = cmbQual.SelectedValue
            txtBasicSal.Text = ""
            btnSave.Text = "&Save"
            btnDelete.Enabled = False
            txtFname.Tag = "<First Name>"
            txtMname.Tag = "<Middle Name>"
            txtLname.Tag = "<Last Name>"
            txtFname.Text = txtFname.Tag
            txtMname.Text = txtMname.Tag
            txtLname.Text = txtLname.Tag

            'Divya 29/11/2007
            cmbTitle.SelectedValue = Replace(ConfigurationManager.AppSettings("Title"), ".", "")
            cmbTitle.Tag = cmbTitle.SelectedValue

            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtLname.Location = New Point(230, 65)
                txtFname.Location = New Point(346, 65)
                txtMname.Location = New Point(463, 65)
            End If

            lblRs.Text = ConfigurationManager.AppSettings("Currency")
            '>>End Divya
            Call clear_addr()
            Call ClearAddress()
            Call SetcontrolTag()
            'Catch aex As ArgumentException
            '    BCommon.ShowMsgError(10437)
            '    Me.Close()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ClearData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Checks for Updation of information
    Private Function isUpdate() As Boolean
        Try
            If cmbTitle.Text <> cmbTitle.Tag Or Trim(txtFname.Text) <> txtFname.Tag _
            Or Trim(txtMname.Text) <> txtMname.Tag Or Trim(txtLname.Text) <> txtLname.Tag _
            Or Trim(txtBasicSal.Text) <> Trim(txtBasicSal.Tag) Or cmbQual.Text <> cmbQual.Tag _
            Or dtpJoinDate.Text <> dtpJoinDate.Tag Then
                Return True
            Else
                Return isEqual()
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isUpdate")
            Me.Cursor = Cursors.Default
        End Try
    End Function
    'Checks for Updation on the address ingformation

    Private Function isEqual() As Boolean
        'Dim intcount As Integer = 0
        Dim intc As New Integer
        Try
            For intc = 0 To address.Length - 1
                If IsNothing(address(intc)) Then Continue For
                If IsNothing(updtAddress(intc)) Then Me.Cursor = Cursors.Default : Return True : Exit Function
                With address(intc)
                    If updtAddress(intc).City <> .City Or updtAddress(intc).Country <> .Country Or _
                    updtAddress(intc).Description1 <> .Description1 Or updtAddress(intc).Description2 <> .Description2 Or _
                    updtAddress(intc).State <> .State Or updtAddress(intc).PhoneNo1 <> .PhoneNo1 Or _
                    updtAddress(intc).PhoneNo2 <> .PhoneNo2 Or updtAddress(intc).PinCode <> .PinCode Or _
                    updtAddress(intc).EmailID <> .EmailID Or updtAddress(intc).WebSiteAddress <> .WebSiteAddress Then
                        Me.Cursor = Cursors.Default
                        Return True
                        Exit Function
                    End If
                End With
            Next
            Return False
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isEqual")
            Me.Cursor = Cursors.Default
            Return False
        End Try
    End Function

    Private Function isAddressChanged() As Byte
        Try
            If txtAddr1.Text <> txtAddr1.Tag Or cmbCountry.SelectedValue <> cmbCountry.Tag Or _
            cmbState.SelectedValue <> cmbState.Tag Or cmbCity.SelectedValue <> cmbCity.Tag Or Trim(txtPinCode.Text) <> _
            txtPinCode.Tag Or Trim(txtPhone1.Text) <> txtPhone1.Tag Or Trim(txtPhone2.Text) <> txtPhone2.Tag Or txtFax.Text _
            <> txtFax.Tag Or Trim(txtEmail.Text) <> txtEmail.Tag Then
                Return 1
            Else
                Return 0
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isAddressChanged")
            Me.Cursor = Cursors.Default
            Return False
        End Try
    End Function

    Private Sub Display_Empoyee()
        Try
            ClearAddress()
            Call ViewEmpoyee()
            btnSave.Text = "&Update"
            If ConfigurationManager.AppSettings("FormMode") = "R" Then
                btnDelete.Enabled = False
                btnSetUser.Enabled = False
            Else
                btnDelete.Enabled = True
                btnSetUser.Enabled = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "Display_Empoyee")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtBasicSal_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBasicSal.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then cmbAddrType.Focus()
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            e.SuppressKeyPress = Not BCommon.ValidateText(e.KeyCode, "NUM", False)
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBasicSal_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtBasicSal_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBasicSal.KeyUp
        Try
            If (BCommon.IsInteger(txtBasicSal.Text) = False) Then txtBasicSal.Focus() : txtBasicSal.Text = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBasicSal_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtBasicSal_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBasicSal.LostFocus
        Try
            If Trim(txtBasicSal.Text) = "" Then txtBasicSal.Text = "0.00"
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBasicSal_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub txtEmail_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtEmail.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                btnSave.Focus()
            Else
                If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtEmail_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnSrch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSrch.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim form As New frmMasterBrowse
            form.strSearch = "Employee"
            'Rahul_ITS@20072612
            '<<START
            form.StartPosition = FormStartPosition.Manual
            form.Height = MDIPharmacy.MdiScaleHeight
            form.Width = MDIPharmacy.MdiScaleWidth
            Dim pt As New Point
            pt.Y = ((MDIPharmacy.MdiScaleHeight - form.Height) / 2) + MDIPharmacy.pnlHeading.Height + MDIPharmacy.MenuStrip.Height
            pt.X = (MDIPharmacy.MdiScaleWidth - form.Width) / 2
            form.Location = pt
            form.ShowInTaskbar = False
            '>>END
            form.ShowDialog()
            _intEmpID = form.strRecordNo
            Call ClearData()
            If _intEmpID <> 0 Then
                Call Display_Empoyee()
                If flgUser <> 0 Then btnSetUser.Enabled = False
            End If
            'Modified By:-VINIT(2008/01/18)
            Call SetcontrolTag()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSearch_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub SetcontrolTag()
        Try
            cmbTitle.Tag = cmbTitle.Text
            txtFname.Tag = txtFname.Text
            txtMname.Tag = txtMname.Text
            txtLname.Tag = txtLname.Text
            cmbQual.Tag = cmbQual.Text
            dtpJoinDate.Tag = dtpJoinDate.Text
            txtBasicSal.Tag = txtBasicSal.Text
            cmbAddrType.Tag = cmbAddrType.Text
            txtAddr1.Tag = txtAddr1.Text
            cmbCountry.Tag = cmbCountry.SelectedValue
            cmbState.Tag = cmbState.SelectedValue
            cmbCity.Tag = cmbCity.SelectedValue
            txtPinCode.Tag = txtPinCode.Text
            txtPhone1.Tag = txtPhone1.Text
            txtPhone2.Tag = txtPhone2.Text
            txtFax.Tag = txtFax.Text
            txtEmail.Tag = txtEmail.Text
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetcontrolTag")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If (DEmployee.IsEmployeeUsed(_intEmpID)) = 0 Then
                If (DEmployee.DeleteEmployee(_intEmpID)) > 0 Then
                    BCommon.ShowMsgError(10357)
                    txtFname.Focus()
                    DisplayData()
                    If btnSave.Text = "&Update" Then btnSave.Text = "&Save"
                    btnDelete.Enabled = False
                    btnSetUser.Enabled = False
                End If
            Else
                BCommon.ShowMsgError(10356)
                btnDelete.Focus()
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnDelete_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub
End Class